package com.zzr.demo.redis.controller;

import com.zzr.demo.redis.service.RankingListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * @author: xiaomi
 * @date: 2021/10/9
 * @description:
 */
@RestController
@RequestMapping("ranking/news")
@Api(tags = "排行榜：新闻排行")
@Slf4j
public class NewsRankingListController {

    @Autowired
    RankingListService rankingListService;

    @GetMapping("/addItem/{name}/{score}")
    @ApiOperation("新增项目")
    public boolean addItem(@PathVariable("name") String name, @PathVariable("score") int score) {
        boolean b = rankingListService.addItem(name, score);
        return b;
    }


    @GetMapping("/getRevRankingList")
    @ApiOperation("获取分数降序的排行")
    public List<String> getRevRankingList() {
        List<String> revRankingList = rankingListService.getRevRankingList();
        return revRankingList;
    }


}
